{% extends "manage/layout.html" %}

{% set page_title = '渠道二维码管理' %}

{% block css %}
<style type="text/css">
	#createmodal .modal-body{
		margin:20px 0 10px 10%;
	}
	.classroom{
		color: red;
	}
	.system{
		color: #545454;
	}
</style>
{% endblock %}

{% block content %}
<div class="m-content">
    {% if current_user.has_permission('EDIT') -%}
    <a class="btn btn-default" href="{{ url_for('manage.exhibition_add') }}">添加渠道信息</a>
    {%- endif %}
    <a class="btn btn-primary" href="{{ url_for('manage.get_wx_groups') }}">微信分组管理</a>
	<table class="table table-striped table-condensed table-bordered table-hover">
		<thead>
			<tr>
				<th>名称</th>
				<th>地址</th>
				<th>微信分组名称</th>
				<th>二维码</th>
                {% if current_user.has_permission('EDIT') -%}
				<th>管理</th>
                {%- endif %}
			</tr>
		</thead>
		<tbody>
			{% for exh in exhibitions %}
			<tr id="{{ exh.id }}">
				<td>{{ exh.name }}</td>
				<td>{{ exh.address }}</td>
				<td>{{ exh.wx_group_name }}</td>
                <td>
                    <img style="width:145px;height:145px;" src="{{ url_for('manage.get_qr_code_url', exh_id=exh.id) }}" />
                    <a href="javascript:;" onclick="location.href='{{ url_for('manage.get_qr_code_url', exh_id=exh.id) }}?exh_name={{ exh.name }}'">下载</a>
                </td>
                {% if current_user.has_permission('EDIT') -%}
				<td>
                    <a href="{{ url_for('manage.exhibition_edit', exh_id=exh.id) }}"><span class="glyphicon glyphicon-edit"></span></a>
                    <a href="javascript:;"><span class="glyphicon glyphicon-trash"></span></a>
				</td>
                {%- endif %}
			</tr>
			{% endfor %}
		</tbody>
	</table>
{% include "school/pagination.html" %}
</div>

<div class="modal modal-confirm">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title">确认删除</h4>
			</div>
			<div class="modal-body">
				<button class="btn btn-danger">确认</button>
				<button class="btn btn-default btn-close">取消</button>
			</div>
		</div>
	</div>
</div>
{% endblock %}

{% block js%}
<script>
$(function(){

	// click trash
	$('span.glyphicon-trash').bind('click',function(){
		var exh_id = $(this).parent().parent().parent().attr('id');
		$('.modal-confirm').modal('show');

		// click modal alert confirm button
		$('.modal-confirm .btn-danger').bind('click',function(){
		    window.location.href = "/manage/exhibition_del/" + exh_id;
		});
	});

	// click modal alert confirm/cancal button
	$('.modal-confirm .btn-close').bind('click',function(){
		$('.modal-confirm').modal('hide');
	});
});
</script>
{% endblock %}
